
from view.endSrc.MyLogger import MyLogger
from view.endSrc.MyTools import MyTools


class DBConfig:
    '''
       Setting database configuration here,
       So that MySqlConn class can use it.
    '''

    _logger = None

    def __init__(self, loggerName=None):

        self.host = '127.0.0.1'
        self.port = 3306
        self.passwd = ""
        self.db = "inicedb_test"
        # self.db = "inicedb_show"
        self.user = 'root'
        self.dataFilesRelPathPrefix = MyTools.getBrotherDir('data')  # relative path to save dataFiles from database tables.

        # create individual logger for input loggerName
        if loggerName is not None:
            self.logger = MyLogger(loggerName)
            return

        # global logger
        if DBConfig._logger is None:
            name = 'DBConfigLog'
            DBConfig._logger = MyLogger(name)

        self.logger = DBConfig._logger



if __name__ == '__main__':

    d = DBConfig('tdatasetlog')

    for i in range(10):
        d.logger.write("tdatasetlog...write..." + str(i))

    g = DBConfig()

    for j in range(100, 1000):
        g.logger.write('global...write...' + str(j))